<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客编辑页</title>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/blog_edit.css">
    <script src="js/jquery.min.js"></script>
    <!-- 引入editor.md -->
    <link rel="stylesheet" href="editor.md/css/editormd.min.css">
    <script src="editor.md/lib/marked.min.js"></script>
    <script src="editor.md/lib/prettify.min.js"></script>
    <script src="editor.md/editormd.min.js"></script>
</head>
<body>
    <!--导航栏-->
    <div class="nav">
        <img src="image/log1.png" alt="">
        <span>我的博客系统</span>
        <!--这个div仅用于占位-->
        <div class="zhan"></div>

        <a href="blog_list.html">主页</a>
        <a href="blog_edit.html">写博客</a>
        <a href="logout">注销</a>
    </div>
    <!--编辑页-->
    <div class="blog-edit-container">
        <form action="blog" method="post" style="height: 100%;">
            <!--博客标题编辑-->
            <div class="title">
                <input type="text" id="title" placeholder="请输入文章标题" name="title">
                <input type="submit" id="submit" value="发布文章">
            </div>
            <!--博客内容-->
            <div id="editor">
                <textarea name="content" style="display: none"></textarea>
            </div>
        </form>
        
    </div>

    <script>
        var editor = editormd("editor",{
            width: "100%",
            height: "calc(100% - 50px)",
            markdown: "#在这里写一篇博客",
            path: "editor.md/lib/"
        });

        function checkLogin(){
            $.ajax({
                type: 'get',
                url: 'login',
                success: function(body){
                    if(body.userId && body.userId > 0){
                        //存在
                        console.log("当前用户已登录");
                    }else{
                        //登陆失败
                        location.assign('login.html');
                    }
                }
            });
        }
        checkLogin();
    </script>
</body>
</html>